home *** CD-ROM | disk | FTP | other *** search
- Path: news.vanderbilt.edu!news
- From: haseltbt@ctrvax.vanderbilt.edu (Bennett Haselton)
- Newsgroups: comp.lang.c++
- Subject: Turbo 3.0 compiler bug -- I MEAN IT!!!!
- Date: 1 Apr 1996 23:35:04 GMT
- Organization: Vanderbilt University
- Message-ID: <4jpp78$85b@news.vanderbilt.edu>
- NNTP-Posting-Host: dial094.vanderbilt.edu
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
-
- Hello world,
-
- i've found what appears to be a bug in the Turbo 3.0 C++
- compiler. Apparently if you write a while loop that is immediately preceded by
- code identical to that contained in the while loop--and the "while" statement
- is true at the time the code immediately preceding it is analyzed--then the
- compiler ignores this extra code preceding the while loop as unnecessary.
- Seems reasonable--equivalent output, right?
- The problem is in the debugging process. i had written code with the
- above-mentioned redundancy to make it easier to read, and in the debugging
- cycle i tried setting breakpoints within the block of "redundant" code. Turbo
- C++ will not allow breakpoints to be set at empty or commented space;
- unfortunately the redundant code was compiled as "empty space" and breakpoints
- were forbidden there. Worse, when the compiler skipped to a breakpoint inside
- the while loop, it became obvious from the values of watch variables that the
- redundant code had been skipped entirely.
- For example:
-
- void main()
- {
- int i, j, k;
- ++i; // (1)
- ++j; // (2)
- ++k; // (3)
- while ( i < 5 )
- {
- ++i; // (4)
- ++j; // (5)
- ++k; // (6)
- }
- }
- During debugging, if breakpoints are set at lines 1, 2, or 3, they will
- generate "invalid breakpoint" messages because this code is apparently ignored.
- If you comment out line (4), for example, then the compiler will allow a
- breakpoint to be set at line (1), because it is no longer redundant, but not at
- lines (2) or (3). Commenting out lines (4) and (5) together produces similar
- results.
- Although the code i wrote contained such a redundancy because it was
- easier to follow that way, a redundancy is not the same as an error, and even
- though the compilation is more efficient, for the purposes of debugging, the
- program may have been better off without this automated streamlining. If you
- have all known about this anomaly of Turbo 3.0 for a while, sorry about
- wasting the bandwidth but it is the first bug i have ever discovered in a
- non-Microsoft application costing > $100 and it was just something i felt
- compelled to share :-).
- Bleep,
-
- tm
- -bennett haselton
-
-